from django.db import models

from wl_AttractionAdmin.models import wl_attractions
from wl_UserAdmin.models import Users



class wl_questions(models.Model):
    """
    问题表
    """
    id = models.AutoField(primary_key=True)  # 问题ID
    core_question = models.CharField(max_length=255)  # 核心问题
    attraction = models.ForeignKey(wl_attractions, on_delete=models.CASCADE)  # 关联的景点ID

    def __str__(self):
        return self.core_question


class wl_similarQuestions(models.Model):
    """
    相似问题表
    """
    id = models.AutoField(primary_key=True)  # 相似问题ID
    question = models.ForeignKey(wl_questions, on_delete=models.CASCADE)  # 关联的核心问题ID
    similar_expression = models.CharField(max_length=255)  # 相似表达


    def __str__(self):
        return self.similar_expression


class wl_answers(models.Model):
    """
    回答表
    """
    id = models.AutoField(primary_key=True)  # 回答ID
    question = models.ForeignKey(wl_questions, on_delete=models.CASCADE)  # 关联的问题ID
    answer_text = models.TextField()  # 回答内容

    def __str__(self):
        return self.answer_text[:50]  # 返回前50个字符作为标识


class wl_similarQuestionWeights(models.Model):
    """
    相似问题权重表
    """
    id = models.AutoField(primary_key=True)  # 权重ID
    question = models.ForeignKey(wl_questions, on_delete=models.CASCADE)  # 问题ID，外键
    similar_question = models.ForeignKey(wl_similarQuestions, on_delete=models.CASCADE)  # 相似问题ID，外键
    weight = models.DecimalField(max_digits=5, decimal_places=2)  # 权重

    def __str__(self):
        return f"相似权重 for {self.question} - {self.similar_question}: {self.weight}"



"""
    将 user_id 字段改为 user，并设置为外键，关联到 Users 模型。这允许你跟踪每个用户的问答历史
"""

